package com.hq.ims.userpc.controller;

import com.hq.ims.data.service.other.BusiInfoStatisticsService;
import com.hq.ims.data.utils.LocalConstant;
import com.hq.ims.data.utils.WebExpandUtils;
import com.hq.ims.userpc.busservice.UserStatisticsService;
import com.hq.ims.userpc.vo.UsertatisticsMapstruct;
import com.hq.utils.util.StringUtils;
import com.hq.utils.vo.ReturnVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yinzhangxiao
 * @date 2024/11/1 13:42
 * @ClassName PlatformStatisticsController
 **/
@Api(tags = "用户端经营信息统计")
@RestController
@RequestMapping(LocalConstant.SYS_TYPE_USER_PC_URL_PREFIX + "/busiInfoStatistics")
public class UserStatisticsController {
    @Resource
    private BusiInfoStatisticsService busiInfoStatisticsService;
    @Resource
    private UserStatisticsService userStatisticsService;

    @ApiOperation(value = "用户端-公司收益信息统计(作为接收者:数量,金额)", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
    })
    @PostMapping(value = "/companyEarningsDateStatistics", consumes = MediaType.APPLICATION_JSON_VALUE)
    public ReturnVo<UsertatisticsMapstruct.CompanyEarningsMoneyStatisticsVo> companyEarningsDateStatistics(
            @RequestBody UsertatisticsMapstruct.StatisticsSearchData searchData
    ) {
        String companyId = StringUtils.ifEmptyDefault(searchData.getOrgId(), WebExpandUtils.getHeadCompanyId());
        searchData.setOrgId(companyId);
        UsertatisticsMapstruct.CompanyEarningsMoneyStatisticsVo companyEarningsMoneyStatisticsVo = userStatisticsService.companyEarningsStatistics(searchData);
        return ReturnVo.buildSuccess(companyEarningsMoneyStatisticsVo);
    }

}
